//
// Created on 2025/3/3.
//
// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found,
// please include "napi/native_api.h".

#ifndef HILOGHOOKER_HILOG_HOOKER_H
#define HILOGHOOKER_HILOG_HOOKER_H

#include "stdint.h"
#include <cstdarg>
#include <cstdint>

#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
    LOG_TYPE_MIN = 0,
    /* app */
    LOG_APP = 0,
    /* system */
    LOG_INIT = 1,
    /* core service */
    LOG_CORE = 3,
    /* kernel message */
    LOG_KMSG = 4,
    LOG_ONLY_PRERELEASE = 5,
    LOG_TYPE_MAX,
} LogType;

typedef enum {
    LOG_LEVEL_MIN = 0,
    LOG_DEBUG = 3,
    LOG_INFO = 4,
    LOG_WARN = 5,
    LOG_ERROR = 6,
    LOG_FATAL = 7,
    LOG_LEVEL_MAX
} LogLevel;

typedef void (*LogCallback)(const LogType type, const LogLevel level, const unsigned int domain, const char *tag,
                            const char *msg);
void LOG_SetCallbacl(LogCallback callback);
int OH_LOG_Print(LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt, ...);
int HiLogPrintArgs(const LogType type, LogLevel level, unsigned int domain, const char *tag, const char *fmt,
                   va_list ap);

typedef struct {
    uint32_t uuid;
    uint32_t fmtOffset;
} FmtId;

int HiLogPrintDict(const LogType type, const LogLevel level, const unsigned int domain, const char *tag,
                   const FmtId *fmtid, const char *fmt, ...) __attribute__((__format__(os_log, 6, 7)));
int HiLogPrintDictNew(const LogType type, const LogLevel level, const unsigned int domain, const char *tag,
                      const unsigned int uuid, const unsigned int fmtOffset, const char *fmt, ...)
    __attribute__((__format__(os_log, 7, 8)));
#ifdef __cplusplus
}
#endif

#ifdef __cplusplus
namespace OHOS {
namespace HiviewDFX {
using HiLogLable = struct {
    LogType type;
    unsigned int domain;
    const char *tag;
};
} // namespace HiviewDFX
} // namespace OHOS
#endif

#endif // HILOGHOOKER_HILOG_HOOKER_H
